package com.lzy.enums;

/**
 * @author lyw
 * @Date 2023/2/14-下午5:52
 */
public enum ExceptionEnums {

  SUCCESS(200, "操作成功"),
  LOGIN_EXCEPTION(400, "登录失败"),
  UNAUTHORIZED(401, "非法访问"),
  NOT_PERMISSION(403, "没有权限访问"),
  NOT_FOUND(404, "你请求的资源不存在"),
  USER_NOT_FOUND(407, "用户不存在"),
  USER_ALREADY_EXISTS(408, "用户已存在"),
  ROLE_ALREADY_EXISTS(418, "角色已存在"),
  SESSION_TIMEOUT(498, "会话已超时，请重新登陆！"),
  FAIL(500, "操作失败"),
  SYSTEM_EXCEPTION(5000, "系统异常"),
  PARAMETER_EXCEPTION(501, "请求参数校验异常"),
  PARAMETER_PARSE_EXCEPTION(502, "请求参数解析异常"),
  HTTP_MEDIA_TYPE_EXCEPTION(503, "HTTP内容类型异常"),
  BUSINESS_EXCEPTION(504, "业务处理异常"),
  PASSWORD_NOT_MATCH(505, "密码与原密码不匹配"),
  YSHOP_SYSTEM_EXCEPTION(510, "系统处理异常"),
  DAO_EXCEPTION(512, "数据库处理异常"),
  VERIFICATION_CODE_EXCEPTION(513, "验证码校验异常"),
  AUTHENTICATION_EXCEPTION(514, "登录授权异常"),
  NO_PERMISSION_OPERATION(515, "没有权限操作"),
  UNAUTHORIZED_EXCEPTION(516, "没有访问权限"),
  JWTDECODE_EXCEPTION(517, "Token解析异常"),
  HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION(518, "METHOD NOT SUPPORTED"),
  BAD_LIMIT_EXCEPTION(519, "访问次数受限制");

  private final int code;
  private final String message;

  private ExceptionEnums(final int code, final String message) {
    this.code = code;
    this.message = message;
  }

  public static ExceptionEnums getApiCode(int code) {
    ExceptionEnums[] ecs = values();
    ExceptionEnums[] var2 = ecs;
    int var3 = ecs.length;

    for(int var4 = 0; var4 < var3; ++var4) {
      ExceptionEnums ec = var2[var4];
      if (ec.getCode() == code) {
        return ec;
      }
    }

    return SUCCESS;
  }

  public int getCode() {
    return this.code;
  }

  public String getMessage() {
    return this.message;
  }
}
